// Package ntlmssp provides NTLM/Negotiate authentication over HTTP // // Protocol details from https://msdn.microsoft.com/en-us/library/cc236621.aspx, // implementation hints from http://davenport.sourceforge.net/ntlm.html . // This package only implements authentication, no key exchange or encryption. It // only supports Unicode (UTF16LE) encoding of protocol strings, no OEM encoding. // This package implements NTLMv2.
package ntlmssp import ( ) func getNtlmV2Hash(, , string) []byte { return hmacMd5(getNtlmHash(), toUnicode(strings.ToUpper()+)) } func getNtlmHash( string) []byte { := md4.New() .Write(toUnicode()) return .Sum(nil) } func computeNtlmV2Response(, , , , []byte) []byte { := []byte{1, 1, 0, 0, 0, 0, 0, 0} = append(, ...) = append(, ...) = append(, 0, 0, 0, 0) = append(, ...) = append(, 0, 0, 0, 0) := hmacMd5(, , ) return append(, ...) } func computeLmV2Response(, , []byte) []byte { return append(hmacMd5(, , ), ...) } func hmacMd5( []byte, ...[]byte) []byte { := hmac.New(md5.New, ) for , := range { .Write() } return .Sum(nil) }